<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<!-- 下面这句会自动查找引入进来的工具类脚本。 -->
	<link rel="stylesheet" href="./layui/css/layui.css"  media="all">
	<!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>

<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
	<legend>订单确认页面</legend>
</fieldset>
<table class="layui-hide" id="test" lay-filter="test"></table>

<script type="text/html" id="barDemo">
	{{#  if(d.orderStaus == 0){ }}
	<a class="layui-btn layui-btn-xs" lay-event="untreated">未处理</a>
	{{# }if(d.orderStaus == 1) { }}
	<a class="layui-btn layui-btn-xs layui-btn-disabled">已处理</a>
	{{# }if(d.orderStaus == 2) { }}
	<a class="layui-btn layui-btn-xs layui-btn-disabled">已过期</a>
	{{#  } }}
</script>

<script src="./layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
 
<script>
layui.use(['table','layer','util'],function(){
	var ws = new WebSocket("ws://192.168.1.116:8080");
	// 连接成功
    ws.onopen = function (e) {
        console.log('连接成功获取到的上半段脚本定义的用户id',selfid);
    }
	var table = layui.table,
		layer = layui.layer,
		util = layui.util; //注意这行，很重要
	var data_index = {"id":selfid};
	console.log(data_index,'数据转换');
	layui.jquery.post("/order_data",data_index,function(result){
		if(result.status == "success"){
			layer.msg('成功打开订单数据');	// 弹出提示
			console.log(result.order_data,'有数据吗');
			table.render({
				elem: '#test',
				title: '订单记录',
				totalRow: true,
				cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
				cols: [[
					//订单号/用户id/收款账号/用户姓名/业务类型/订单金额/订单状态/下单时间
					{field:'orderNum', width:80, title:'订单号', sort: true,unresize: true,totalRowText: '合计'},
					{field:'orderId', width:80, title:'用户id', sort: true},
					{field:'orderCount', width:80, title:'收款账号', sort: true},
					{field:'orderName', width:80, title:'用户姓名', sort: true},
					{field:'orderType_yewu', width:80, title:'业务类型', sort: true},
					{field:'orderAmount', width:80, title:'订单金额', sort: true},
      				{field:'orderStaus', title:'订单状态', toolbar: '#barDemo',width:250,align: 'center'},
					{field:'orderTime', width:80, title:'下单时间', sort: true,templet:"<div>{{layui.util.toDateString(d.createTime)}}</div>"},
				]],
				data: [{
					orderNum:001,
					orderId:15645454,
					orderCount:1234567,
					orderName:1234567,
					orderType_yewu:1234567,
					orderAmount:1234567,
					orderStaus:0,
					orderTime:0,
				}],		// 数据赋值
				page: true,
			});
			//监听行工具事件
			table.on('tool(test)', function(obj){
				var data = obj.data;
				if(obj.event === 'untreated') {
					console.log('未处理');
				}
			});
		}
		else{
			layer.msg("错误信息:"+result.status);
		}
	});
});
</script>
</body>
</html>